<div class="modal-dialog" role="document">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" id="advPlaceAddBtn" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title" id="exampleModalLabel">添加轮播位</h4>
        </div>
        <form class="form-horizontal" style="margin:4%;"  id="addAdvPlaceForm" data-toggle="validator">
            <div class="form-group">
                <label for="recipient-name" class="control-label col-sm-3"><span style="color:red;">*</span>广告位名称:</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="name" value="" placeholder="请输入广告位名称" required>
                </div>
            </div>
            <div class="form-group">
                <label for="recipient-name" class="control-label col-sm-3"><span style="color:red;">*</span>唯一标识(英文):</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control" name="flag" value="" pattern ="^\w+$" data-error="唯一标识为英文字母!" placeholder="请输入唯一标识(英文)" required>
                </div>
               <div class="help-block with-errors"></div>
            </div>
            <div class="form-group">
                <label for="recipient-name" class="control-label col-sm-3">内容描述:</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" name="introduce" value="" placeholder="请输入内容描述">
                </div>
            </div>
            <div class="form-group">
                <label for="recipient-name" class="control-label col-sm-3"><span style="color:red;">*</span>宽度限制:</label>
                <div class="col-sm-3">
                    <input type="text" class="form-control" name="width" value="" placeholder="请输入宽度"  pattern ="^[0-9]+$" data-error="宽度只能为数字!" required>
                </div>
                <div class="help-block with-errors"></div>
            </div>
            <div class="form-group">
                <label for="recipient-name" class="control-label col-sm-3"><span style="color:red;">*</span>高度限制:</label>
                <div class="col-sm-3">
                    <input type="text" class="form-control" name="height" value="" placeholder="请输入高度"  data-error="高度只能为数字!" pattern ="^[0-9]+$" required>
                </div>
                <div class="help-block with-errors"></div>
            </div>
            <div class="form-group">
                <label for="message-text" class="control-label col-sm-3"><span style="color:red;">*</span>显示位置:</label>
                <div class="col-sm-3">
                    <!--<select name="prid" class="form-control">
                        <option>index</option>
                        <option>left</option>
                        <option>right</option>
                        <option>foot</option>
                    </select>-->
                    <input type="text" class="form-control " name="place" value="" placeholder="请输入位置" required>
                </div>
            </div>
            <div class="form-group">
                <label for="message-text" class="control-label col-sm-3">优先级:</label>
                <!--<label class="control-label">Select - Basic</label>-->
                <div class="col-sm-2">
                    <!--<select name="position" class="form-control">
                        <option>1</option>
                        <option>2</option>
                        <option>3</option>
                        <option>4</option>
                    </select>-->
                    <input type="text" class="form-control " name="position" value="" >
                </div>
            </div>
        </form>
        <div class="modal-footer">
            <button type="button" data-dismiss="modal" class="btn btn-default">取消</button>
            <button type="button" id="advPlaceAdd" class="btn btn-primary">保存</button>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('#addAdvPlaceForm').validator();
    })

    $("#advPlaceAdd").click(function () {
        var validator = $("#addAdvPlaceForm").data("bs.validator");
        validator.validate();
        if(!validator.hasErrors()) {
            $.ajax({
                url: "{:U('Admin/Content/addAdvPlace')}",
                type: "post",
                dataType: "json",
                data: $("#addAdvPlaceForm").serialize(),
                success: function (data) {
                    $("#commonModal").modal('toggle');
                    window.location.reload();
                }
            })
        }
    })
</script>